<!--  -->
<template>
  <div class="share-order">
    <div class="scroll-wrap">
      <Scroll
        :click="true"
        :tap="true"
        :pullup="true"
        :pulldown="true"
        @scrollToEnd="scrollToEnd"
        :data.sync="overdueList"
        :preventDefault="true"
        ref="myScroll"
      >
        <div>
          <template v-for="(item,index) in overdueList">
            <router-link
              tag="div"
              :to="{name:'recordList',params:{id:activityId,issue_id:item.issue_id,key:item.key}}"
              :class="[index==0?'pt-10':'mt-12']"
              class="over-item"
              :key="index"
            >
              <div class="flex aligin-center justify-between">
                <div class="label-wrapper">
                  <div class="flex">
                    <div class="flex label-item aligin-center">
                      <span class="f-12 f-medium ml-6">期号:</span>
                      <span class="f-14 f-medium mr-auto ml-auto">{{item.issue_id}}</span>
                    </div>
                    <div class="flex label-item justify-between aligin-center">
                      <span class="f-12 f-medium ml-6 mr-auto">幸运号:</span>
                      <span class="f-14 f-medium color-red">{{item.luck_number}}</span>
                    </div>
                  </div>
                  <div class="flex mt-14">
                    <div class="flex label-item aligin-center">
                      <span class="f-12 f-medium ml-6">幸运者:</span>
                      <span class="f-12 f-medium mr-auto ml-auto ellipsis w-100">{{item.nick_name}}</span>
                    </div>
                    <div class="flex label-item justify-between aligin-center">
                      <span class="f-12 f-medium ml-6 mr-auto">揭晓:</span>
                      <span class="f-10 color-gray f-medium">{{item.open_time}}</span>
                    </div>
                  </div>
                </div>
                <span class="arrow-right"></span>
              </div>
            </router-link>
          </template>
          <div class="no-data" v-if="overdueList.length==0"></div>
          <div class="loading-bottom mt-10 f-14" v-if="loading">加载中...</div>
          <div class="loading-bottom mt-10 f-14" v-if="noMore">没有更多了</div>
        </div>
      </Scroll>
    </div>
  </div>
</template>

<script>
import Scroll from "./Scroll";
import Page from "../mixin/page";
import { activityHistories } from "../api/api";
export default {
  mixins: [Page],
  components: { Scroll },
  props: {
    activityId: {
      type: Number,
      default: () => {
        return 0;
      },
      required: true
    }
  },
  watch: {
  },
  data() {
    return {
      overdueList: []
    };
  },
  computed: {},
  watch: {},
  methods: {
    reset() {
      this.current_page = 0;
      this.last_page = 1;
      this.overdueList = [];
      this.loading = false;
      this.$emit("closeDialog");
    },
    request() {
      this._api();
    },
    _api() {
      activityHistories({
        page: this.current_page + 1,
        id: this.activityId
      }).then(({ data: { result } }) => {
        if (result && result.length != 0) {
          this.overdueList = [...this.overdueList, ...result];
          this.current_page += 1;
          this.last_page = this.current_page + 1;
        } else {
          this.last_page = this.current_page;
        }
        this.loading = false;
      });
    }
  },
  created() {},
  mounted() {
    this.request()
  },
  updated() {}, //生命周期 - 更新之后
  destroyed() {} //生命周期 - 销毁完成
};
</script>
<style lang='less' scoped>
@import url("../assets/style/mixin"); //引入公共css类
.mask {
  position: fixed;
  top: 0;
  left: 0;
  height: 100%;
  width: 100%;
  background: rgba(0, 0, 0, 0.4);
  opacity: 0.4;
  z-index: 30;
}
.share-order {
  padding: 90px 14px 0;
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  z-index: 32;
  background: #fff;
  transition: all 0.3s ease;
  border-top-left-radius: 10px;
  border-top-right-radius: 10px;
  .share-icon {
    width: 24px;
    height: 24px;
    .bg-image("../../assets/imgs/share-order");
    background-size: 100% 100%;
  }
  .close {
    height: 16px;
    width: 16px;
    .bg-image("../../assets/imgs/close-dialog");
    background-size: 100% 100%;
  }
  .scroll-wrap {
    height: 100%;
    overflow: hidden;
    img {
      height: 25px;
      width: 25px;
      border-radius: 50%;
    }
    .loading-bottom {
      width: 100%;
      text-align: center;
    }
  }
}
.show {
  height: 543px;
}
.label-wrapper {
  width: 95%;
  .label-item {
    width: 50%;
  }
}
.arrow-right {
  width: 14px;
  height: 14px;
  background: url("../assets/imgs/arrow-right-b@2x.png");
  background-size: 100% 100%;
}
.over-item {
  padding: 20px 0;
  border-bottom: 1px solid rgba(248, 248, 248, 1);
}
.w-100 {
  max-width: 100px;
  height: 16px;
  line-height: 16px;
}
</style>